package com.lovo.manage.service;

import com.lovo.manage.bean.Pagination;
import com.lovo.manage.bean.Student;
import com.lovo.manage.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class StudentService {
    @Autowired
    private StudentMapper studentMapper;
    private Pagination pagination;

    public Pagination find(int page, int rows){
        int total = studentMapper.getCount();
        pagination = new Pagination();
        pagination.setTotal(total);
        pagination.setRows(studentMapper.find((page - 1) * rows,rows));
        pagination.setCurpage(page);
        pagination.setEachpage(rows);
        return pagination;
    }

    public Student findById(int id){
        return studentMapper.findById(id);
    }

    public void addStudent(Student student){
        studentMapper.addStudent(student);
    }

    public void updateStudent(Student student){
        studentMapper.updateStudent(student);
    }

    public void delStudent(int id){
        studentMapper.delStudent(id);
    }


}
